import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.google.gson.Gson;
import com.guigu.www.pojo.Employee;
import com.guigu.www.service.EmployeeService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:applicationContext.xml"})
public class test3 {
    @Autowired
    EmployeeService employeeService;
    @Test
    public void t1(){
        Employee employee = employeeService.selectById(1);
        System.out.println(employee);
    }
    @Test
    public void t2(){
        Page<Employee> page=new Page<>(2,2);
        Page<Employee> page1 = employeeService.selectPage(page);
        Gson gson=new Gson();
        String s = gson.toJson(page1);
        System.out.println(s);
    }
    @Test
    public void t3(){
        EntityWrapper<Employee> wrapper=new EntityWrapper<>();
        wrapper.like("ename", "李");
        wrapper.like("hiredate","20");
        wrapper.like("hiredate","1");
        List<Employee> employees=employeeService.selectList(wrapper);
        System.out.println(employees);
    }
}
